var app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    shopInfo:{
      type:Object,
      value:{}
    },
    userInfo:{
      type:Object,
      value:{}
    }
  },

  /**
   * 组件的初始数据
   */
  data: { 
    isShopContent:false,
    shopContent:"",//公告信息
    noticeText:"",
    isNotice:false
  },
  ready(){

  },
  /**
   * 组件的方法列表
   */
  methods: {
    onClickSel(){
      wx.redirectTo({
        url: '/pages_subpack/pop_shop_address/pop_shop_address'
      })
    },
    // 判断是否打样
    shopInfo(){
      let shop = app.functions.getLocalStorage("shop");
      if (app.functions.isEmpty(shop)) return;
      
      if (new Date((shop.sleepStartTime).replace(/-/g, '/')).getTime() < new Date().getTime() && new Date().getTime() < new Date((shop.sleepEndTime).replace(/-/g, '/')).getTime()){
        this.setData({
          isNotice:true,
          noticeText: '店铺打烊  ' + app.functions.dateTimeFormat(shop.sleepStartTime, 'YYYY-MM-DD HH:mm') + '至' + app.functions.dateTimeFormat(shop.sleepEndTime,'YYYY-MM-DD HH:mm')
        })
      }else{
        this.setData({
          isNotice: false
        },()=>{
          this.ShopNotice();
        })
      }
    },
    // 公告
    ShopNotice(){
      let shop = app.functions.getLocalStorage("shop");
      let params={
        centerId: shop.centreId
      };
      app.api.ShopNotice(params,(response)=>{
        if(response.data.rows.length>0){
          this.setData({
            content:response.data.rows[0].content,
            isShopContent:true
          })
        }else{
          this.setData({
            content:'',
            isShopContent:false
          })
        }
      },(e)=>{
        app.functions.showToast(e.msg);
      })
    }
  }
})
